home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Wonky Flux Batch 2019 02
/
Wonky_Flux_Batch_2019-02.zip
/
Wonky Flux Batch 2019-02
/
089 - Misc Stuff - PD.dsk
/
FLOAT.S
< prev
next >
Wrap
Text File
|
2019-02-17
|
5KB
|
189 lines
********************************
* *
* FLOAT auxiliary psuedo-op. *
* *
* [ USR opcode example ] *
* *
* Glen Bredon 1/10/82 *
* *
********************************
* *
* BRUN from EXEC to set up USR *
* *
* USR decimal # then puts *
* the 5 byte packed FP number *
* in the object code. *
* *
* EXAMPLES: USR 3.1459266 *
* USR 5.2E10 *
* *
********************************
* *
* CAUTIONS: *
* *
* You can use this routine *
* only if you have Applesoft *
* on the MOTHERBOARD!!!!! *
* *
* There is no syntax check in *
* the Applesoft routine FIN *
* that is used here. *
* *
* The DOS buffers MUST be in *
* standard positions! *
* *
********************************
TR
EXP OFF
PASSNUM = 2 ;Assembler's pass number
ERRCNT = $1D ;Assembler's error count
OPNDLEN = $BB ;Operand length
WORKSP = $280 ;Holds operand and comment
USRADR = $B6DA ;Must contain JMP to USR routine
PUTBYTE = $E5F6 ;Stable entry to asm code (in A)
; (preserves Y, but not A or X)
BASIC = $E000
COUT = $FDED
KEY = $C000
STROBE = $C010
DOSBUF = $9AA6 ;2nd buffer (cannot be in
; use when calling this.)
* Applesoft stuff:
ZPSTUFF = $F10B ;CHRGET routine
LINNUM = $50
TXTTAB = $67
CURLIN = $75
CHRGET = $B1
CHRGOT = $B7
TXTPTR = $B8
FPGEN = $A4
ERRFLG = $D8
TXTPSV = $F4
FIN = $EC4A ;Floats dec # at TXTPTR
MOVMF = $EB2B ;Packs & moves FAC to (X,Y)
* Ramcard stuff:
CONTROL = $C080
ROMREAD = %10
ENABLE = %11
BANK1 = %1000
ORG $2F0
DO 0
STADR MAC
LDA #]1
STA ]2
LDA #>]1
STA ]2+1
<<<
FIN
* Setup routine on BRUN:
LDA #$4C
STA USRADR
>>> STADR.ENTRY;USRADR+1
RTS
ERR ERROR-$300 ;ERROR must be at $300
ERROR LDX STKSV ;Comes here on FP error
TXS
JSR ZPBACK
LDY #ILLQUAN-MSGS
BNE SNDMSG ;Always taken
ENTRY BIT BASIC ;Is Applesoft on motherboard?
BVC FLOAT ;Branch if so
;Else send error Y=0
SNDMSG LDA MSGS,Y
BEQ KEYWAIT
JSR COUT
INY
BNE SNDMSG ;Always taken
KEYWAIT BIT STROBE
GK LDA KEY ;Wait for keypress
BPL GK
INC ERRCNT
RTS ;Dont reset STROBE,
;Asm will do it
FLOAT LDY OPNDLEN
STA WORKSP,Y ;So Applesoft will stop
TAY
LDA PASSNUM
BEQ MAKCODE ;Doesn't matter what we
; send on first pass.
DOFLT LDA 0,Y ;Save all zero page
STA DOSBUF,Y ; in 2nd DOS buffer
INY ; (which is free)
BNE DOFLT
TSX ;Save stack pointer in case
STX STKSV ; of Applesoft error.
;The FP routines we will use will
; not destroy our rtn adrs.
BIT CONTROL!ROMREAD ;Turn on Applesoft
LDX #$1C ;Set up Applesoft's CHRGET
MVZP LDA ZPSTUFF-1,X
STA CHRGET-1,X
DEX
BNE MVZP
STX FPGEN ;And some other stuff
STX CURLIN+1 ;These equal forces ONERR
STX LINNUM+1 ; to look at prog beginning.
ROR ERRFLG ;Set ONERR, carry is set
>>> STADR.ERRCALL;TXTPSV
>>> STADR.GOTOLN;TXTTAB
>>> STADR.WORKSP;TXTPTR
JSR CHRGOT ;FIN routine needs this
JSR FIN ;Get FP # at TXTPTR
LDX #WORKSP ;Set up to move FAC
LDY #>WORKSP ; to WORKSP
JSR MOVMF ;Move it
JSR ZPBACK ;Replace zero page
MAKCODE LDA WORKSP,Y ;Send the packed # to asm
JSR PUTBYTE
INY
CPY #5 ; 5 bytes of it
BLT MAKCODE
RTS ;Return to asm
;(which prints the USR line)
ZPBACK LDY #0 ;Replace zero page
LUP 2
BIT CONTROL!ENABLE!BANK1
--^
ZB LDA DOSBUF,Y
STA 0,Y
INY
BNE ZB
RTS
MSGS HEX 878D
ASC "APPLESOFT NOT FOUND"
HEX 8D00
ILLQUAN HEX 878D
ASC "ILLEGAL QUANTITY"
HEX 8D00
GOTOLN DFB TWOBRK,>TWOBRK,0,0 ;Link and line # (0)
DFB $8C ;CALL token
ASC '768'
BRK
ERRCALL ASC '0'
TWOBRK BRK
BRK
STKSV DS 1
ERR STKSV/$3D0